package com.selfdiscipline.data.model

import androidx.room.Entity
import androidx.room.PrimaryKey
import androidx.room.ColumnInfo
import androidx.room.Relation
import java.util.Date
import java.util.UUID

/**
 * Task entity for the Room database
 */
@Entity(tableName = "tasks")
data class Task(
    @PrimaryKey
    val id: String = UUID.randomUUID().toString(),
    
    @ColumnInfo(name = "title")
    val title: String,
    
    @ColumnInfo(name = "description")
    val description: String? = null,
    
    @ColumnInfo(name = "created_at")
    val createdAt: Date = Date(),
    
    @ColumnInfo(name = "deadline")
    val deadline: Date? = null,
    
    @ColumnInfo(name = "priority")
    val priority: TaskPriority = TaskPriority.MEDIUM,
    
    @ColumnInfo(name = "estimated_time_minutes")
    val estimatedTimeMinutes: Int? = null,
    
    @ColumnInfo(name = "completed")
    val completed: Boolean = false,
    
    @ColumnInfo(name = "completed_at")
    val completedAt: Date? = null,
    
    @ColumnInfo(name = "parent_task_id")
    val parentTaskId: String? = null
)

/**
 * Enum representing task priority levels
 */
enum class TaskPriority {
    HIGH,
    MEDIUM,
    LOW
}

/**
 * Data class that includes a task and its subtasks
 */
data class TaskWithSubtasks(
    @Relation(
        parentColumn = "id",
        entityColumn = "parent_task_id"
    )
    val subtasks: List<Task>,
    
    @ColumnInfo(name = "task")
    val task: Task
) 